package com.ecoolex.ying.space.api.graphql;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.lang.NonNull;

import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module;
import com.ecoolex.framework.web.api.graphql2.annotation.QueryField;
import com.ecoolex.framework.web.api.graphql2.annotation.Source;
import com.ecoolex.framework.web.api.graphql2.annotation.TypeField;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module.Type;
import com.ecoolex.ying.space.entity.UserWorks;
import com.ecoolex.ying.space.entity.UserWorksMarkting;
import com.ecoolex.ying.space.entity.UserWorksMarktingDetail;
import com.ecoolex.ying.space.ws.UserWorksMarktingService;
import com.ecoolex.ying.space.ws.UserWorksService;

@GraphQL2Module(type = Type.User, description = "作品营销位管理")
public class UserWorksMarktingGraphql {
	
	@Reference
	private UserWorksMarktingService userWorksMarktingService;
	
	@Reference
	private UserWorksService userWorksService;
	
	@TypeField(type = UserWorksMarktingDetail.class,field = "userWorks",description = "作品")
	public UserWorks userWorks(@Source UserWorksMarktingDetail source) {
		return userWorksService.getUserWorksById(source.getWorksId());
	}
	
	@TypeField(type = UserWorksMarkting.class,field = "detailList",description = "营销位明细列表")
	public Pagination<UserWorksMarktingDetail> detailList(@Source UserWorksMarkting source,@NonNull Page page){
		return userWorksMarktingService.queryDetailByMarktingId(source.getMarktingId(), page);
	}
	
	@QueryField(field = "userWorksMarktingList", description = "作品营销位列表")
	public Pagination<UserWorksMarkting> query(@NonNull Page page){
		return userWorksMarktingService.query(page);
	}
	
	@QueryField(field = "userWorksMarkting", description = "作品营销位")
	public UserWorksMarkting get(@NonNull Integer marktingId) {
		return userWorksMarktingService.get(marktingId);
	}
}
